﻿using AutoMapper;
using Model;
using ModelDto.Response;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public class MapperProfile: Profile
    {
        public MapperProfile() 
        {
            //双向映射 MemberList.None 忽略不同字段
            //CreateMap<dto,entity>(MemberList.None).ReverseMap();

            //指定字段映射对应字段
            //CreateMap<Stu1, StuDto>().ForMember(x => x.Id, p => p.MapFrom(p => p.No));

            //实体转DTO,数据内容进行转换 Stu2 性别是 1和0 转成 StuDto1 中的男和女
            //CreateMap<Stu1, StuDto1>().ForMember(x => x.Sex, p => p.MapFrom(p => p.Sex == true ? "男" : "女"));

            //忽略字段
            //Dto转实体忽略Id
            //CreateMap<StuDto2, Stu2>().ForMember(x => x.Id, p => p.Ignore());

            //实体嵌套实体映射dto
            //CreateMap<City, CityDto>();
            //CreateMap<Area, AreaDto>().ForMember(x => x.AreaId1, p => p.MapFrom(p => p.AreaId))
            //                        .ForMember(x => x.AreaName1, p => p.MapFrom(p => p.AreaName));
            CreateMap<PrintTempResponse,PrintTemp>(MemberList.None).ReverseMap();
        }
    }
}
